#include "timer.h"


void TIME_Initconfig(uint16_t Period,uint16_t Prescaler)
{
  TIM_TimeBaseInitTypeDef  TIM_TimeBaseStructure;
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2,ENABLE);
  
  TIM_TimeBaseStructure.TIM_Period        = Period;
  TIM_TimeBaseStructure.TIM_Prescaler     = Prescaler;
  TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
  TIM_TimeBaseStructure.TIM_CounterMode   = TIM_CounterMode_Up;
  TIM_TimeBaseInit(TIM2,&TIM_TimeBaseStructure);
  
  TIM_ARRPreloadConfig(TIM2,ENABLE);
  TIM_ClearFlag(TIM2,TIM_FLAG_Update);
  TIM_ITConfig(TIM2,TIM_IT_Update,ENABLE);
  TIM_Cmd(TIM2,ENABLE);
}

void TIM2_IRQHandler(void)
{
  if(TIM_GetITStatus(TIM2,TIM_IT_Update) != RESET)
  {
    TIM_ClearITPendingBit(TIM2,TIM_FLAG_Update);
    rs485_headle.receive_tiem--;
    rs485_headle.status = 'V';
  }
}









